package Box2D.Dynamics
{
	import Box2D.Collision.Shapes.b2MassData;
	import Box2D.Collision.Shapes.b2Shape;
	import Box2D.Common.Math.b2Transform;
	import Box2D.Common.Math.b2Vec2;
	import Box2D.Common.b2Wrapper;
	
	import mx.core.mx_internal;
	
	public class b2Body extends b2Wrapper
	{
		mx_internal var _world:b2World;
		private var _userData:*;
		private var _transform:b2Transform;
		public function b2Body()
		{
			super();
		}
		public override function set wrapper(value:Object):void{
			super.wrapper = value;
			_transform = new b2Transform(call('b2Body_GetTransform'));
		}
		public function CreateFixture(def:b2FixtureDef):b2Fixture{
			var fixture:b2Fixture = new b2Fixture;
			fixture.wrapper = call('b2Body_CreateFixture',def.wrapper,fixture);
			return fixture;
		}
		public function CreateFixtureByShape(shape:b2Shape,density:Number):b2Fixture{
			var fixture:b2Fixture = new b2Fixture;
			fixture.wrapper = call('b2Body_CreateFixtureByShape',shape.wrapper,density,fixture);
			return fixture;
		}
		public function DestroyFixture(fixture:b2Fixture):void{
			call('b2Body_DestroyFixture',fixture.wrapper);
		}
		public function SetTransform(position:b2Vec2,angle:Number):void{
			call('b2Body_SetTransform',position.wrapper,angle);
		}
		public function GetTransform():b2Transform{
			return new b2Transform(call('b2Body_GetTransform'))
		}
		public function GetPosition():b2Vec2{return _transform.position}		
		/*
		public function GetPosition():b2Vec2{
			return new b2Vec2(0,0,call('b2Body_GetPosition'));
		}
		*/
		public function GetAngle():Number{
			return call('b2Body_GetAngle');
		}
		public function GetWorldCenter():b2Vec2{
			return new b2Vec2(0,0,call('b2Body_GetWorldCenter'));	
		}
		public function GetLocalCenter():b2Vec2{
			return new b2Vec2(0,0,call('b2Body_GetLocalCenter'));
		}
		public function SetLinearVelocity(v:b2Vec2):void{
			call('b2Body_SetLinearVelocity',v.wrapper);
		}
		public function GetLinearVelocity():b2Vec2{
			return new b2Vec2(0,0,call('b2Body_GetLinearVelocity'));
		}
		public function SetAngularVelocity(omega:Number):void{
			call('b2Body_SetAngularVelocity',omega);
		} 
		public function GetAngularVelocity():Number{
			return call('b2Body_GetAngularVelocity');
		}
		public function ApplyForce(force:b2Vec2,point:b2Vec2):void{
			call('b2Body_ApplyForce',force.wrapper,point.wrapper);
		}
		public function ApplyTorque(torque:Number):void{
			call('b2Body_ApplyTorque',torque);
		}
		public function ApplyLinearImpulse(impulse:b2Vec2,point:b2Vec2):void{
			call('b2Body_ApplyLinearImpulse',impulse.wrapper,point.wrapper);
		}
		public function ApplyAngularImpulse(impulse:Number):void{
			call('b2Body_ApplyAngularImpulse',impulse);
		}
		public function GetMass():Number{
			return call('b2Body_GetMass');
		}
		public function GetInertia():Number{
			return call('b2Body_GetInertia');
		}
		public function GetMassData(data:b2MassData):void{
			call('b2Body_GetMassData',data.wrapper);
		}
		public function SetMassData(data:b2MassData):void{
			call('b2Body_SetMassData',data.wrapper);	
		}
		public function ResetMassData():void{
			call('b2Body_ResetMassData');
		}
		public function GetWorldPoint(localPoint:b2Vec2):b2Vec2{
			return new b2Vec2(0,0,call('b2Body_GetWorldPoint',localPoint.wrapper));
		}
		public function GetWorldVector(localVector:b2Vec2):b2Vec2{
			return new b2Vec2(0,0,call('b2Body_GetWorldVector',localVector.wrapper));
		}
		public function GetLocalPoint(worldPoint:b2Vec2):b2Vec2{
			return new b2Vec2(0,0,call('b2Body_GetLocalPoint',worldPoint.wrapper));
		}
		public function GetLocalVector(worldVector:b2Vec2):b2Vec2{
			return new b2Vec2(0,0,call('b2Body_GetLocalVector',worldVector.wrapper));
		}
		public function GetLinearVelocityFromWorldPoint(worldPoint:b2Vec2):b2Vec2{
			return new b2Vec2(0,0,call('b2Body_GetLinearVelocityFromWorldPoint',worldPoint.wrapper));
		}
		public function GetLinearVelocityFromLocalPoint(localPoint:b2Vec2):b2Vec2{
			return new b2Vec2(0,0,call('b2Body_GetLinearVelocityFromLocalPoint',localPoint.wrapper));
		}
		public function GetLinearDamping():Number{
			return call('b2Body_GetLinearDamping');	
		}
		public function SetLinearDamping(linearDamping:Number):void{
			call('b2Body_SetLinearDamping',linearDamping);
		}
		public function GetAngularDamping():Number{
			return call('b2Body_GetAngularDamping');
		}
		public function SetAngularDamping(angularDamping:Number):void{
			call('b2Body_SetAngularDamping',angularDamping);	
		}
		public function SetGravityScale(scale:Number):void{
			call('b2Body_SetGravityScale',scale);
		}
		public function GetGravityScale():Number{
			return call('b2Body_GetGravityScale');
		}
		public function SetType(type:int):void{
			call('b2Body_SetType',type)
		}
		public function GetType():int{
			return call('b2Body_GetType')
		}
		public function SetBullet(flag:Boolean):void{
			call('b2Body_SetBullet',flag);
		}
		public function IsBullet():Boolean{
			return call('b2Body_IsBullet');
		}
		public function SetSleepingAllowed(flag:Boolean):void{
			call('b2Body_SetSleepingAllowed',flag);
		}
		public function IsSleepingAllowed():Boolean{
			return call('b2Body_IsSleepingAllowed');
		}
		public function SetAwake(flag:Boolean):void{
			call('b2Body_SetAwake',flag);
		}
		public function IsAwake():Boolean{
			return call('b2Body_IsAwake');
		}
		public function SetActive(flag:Boolean):void{
			call('b2Body_SetActive',flag);
		}
		public function IsActive():Boolean{
			return call('b2Body_IsActive');
		}
		public function SetFixedRotation(flag:Boolean):void{
			call('b2Body_SetFixedRotation',flag);
		}
		public function IsFixedRotation():Boolean{
			return call('b2Body_IsFixedRotation');
		}
		public function GetFixtureList():b2Fixture{
			return call('b2Body_GetFixtureList');
		}
		//public function GetJointList():b2JoingEdge{}
		//public function GetContactList():b2ContactEdge{}		
		public function GetNext():b2Body{
			return call('b2Body_GetNext') as b2Body;
		}
		public function GetUserData():*{return _userData}
		public function SetUserData(data:*):void{_userData=data}
		public function GetWorld():b2World{
			return mx_internal::_world;
		}
	}
}